package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @Author: wujian
 * @Description: 退货单 退单类型枚举
 * @Date: 下午10:48 2021/1/28
 * @Param:
 * @return:
 **/
@Getter
public enum ReturnTypeEnum {
    //自主退单
    AUTONOMOUS_RETURN("1","enum.returnType.name.autonomous_return","autonomousReturn","enum.returnType.mallName.autonomous_return"),
    //代客退单
    VALET_RETRUN("2","enum.returnType.name.valet_return","valetReturn","enum.returnType.mallName.valet_return"),
    ;
    private String code;
    private String name;
    private String attr;
    private String mallName;

    ReturnTypeEnum(String code, String name, String attr, String mallName) {
        this.code = code;
        this.name = name;
        this.attr = attr;
        this.mallName = mallName;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
    public String getMallName() {
        return I18nMessageUtil.getMessage(mallName);
    }

    public static String getByCode(String code) {
        for (ReturnTypeEnum typeEnum : ReturnTypeEnum.values()) {
            if (Objects.equals(typeEnum, code)) {
                return typeEnum.getName();
            }
        }
        return "";
    }

    public static String getHelpMark(String code) {
        if (Objects.equals(code, ReturnTypeEnum.VALET_RETRUN.getCode())) {
            return ReturnTypeEnum.VALET_RETRUN.getMallName();
        }
        return "";
    }
}
